package com.yueke.gemini.controller;

import com.yueke.gemini.entity.Page;
import com.yueke.gemini.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;


/**
 *  目录请求web
 * created by admin 2020/3/28 10:34
 */
@Controller
@RequestMapping("/items")
public class ItemController {

	@Autowired
	private ItemService itemService;

	/**
	 *  根据页码查询分页数据
	 * @param pageNum
	 * @return
	 */
	@RequestMapping("/page/{number}")
	public ModelAndView queryByPage(@PathVariable("number") int pageNum){
		ModelAndView mav = new ModelAndView("page");
		Page page = itemService.findByPage(pageNum, 3);
		mav.addObject("page", page);
		return mav;
	}
}
